package com.example.designmode.factoryMethod;

import java.math.BigDecimal;

//除法
public class DivOperation extends OperationAbstract {

    @Override
    public double calculate(double number1, double number2) {
        if (number1 == 0 && number2 == 0) {
            throw new RuntimeException("参数异常 预计出现除零异常");
        }
        BigDecimal bigDecimal = new BigDecimal(number1);
        return bigDecimal.divide(new BigDecimal(number2),2,BigDecimal.ROUND_CEILING).doubleValue();
    }
}
